<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
    <div id="parent">
        <p>第一个</p>
    </div>
    <script>
        /* 
        从父元素的前面插入节点
        insertBefore(newChild,oldChild) */
        var parent=document.getElementById("parent")
        var p=document.createElement("p");  //创建一个p
        var txt=document.createTextNode("第零个") //第二种方法给p增加内容    1.h2.innerHTML="标题";
        p.appendChild(txt)
        parent.insertBefore(p,parent.firstElementChild)
    </script>
</body>
</html>